<?php
  /**
   * This class provides static methods to access and modify the $_COOKIE variable
   * It is recommended to used this instead of accessing the $_COOKIE variable directly
   *
   * @author Macdonald Terrence Robinson
   * @package Core
   *
   */
  final class Cookie
  {
    public static function init()
    {
      if( !isset($_COOKIE) )
        $_COOKIE = array();
    }
    
    public static function getByKey($keyName)
    {
      if(isset($_COOKIE[$keyName]))
        return $_COOKIE[$keyName];
        
      return NULL;
    }

    public static function set($keyName, $keyValue)
    {
      $_COOKIE[$keyName] =  $keyValue;
    }

    public static function remove($keyName)
    {
      if( self::isExists($keyName) )
        unset($array[$keyName]);
    }

    public static function rename($key, $newKey)
    {
      $tmp = $_COOKIE[$key];
      unset($_COOKIE[$key]);
      self::set($newKey, $tmp);
    }

    public static function setAll(array $newArray)
    {
      $_COOKIE = $newArray;
    }

    public static function clear()
    {
      $_COOKIE = array();
    }

    public static function isExists($key)
    {
      if(isset($_COOKIE[$key]))
        return true;
      else
        return false;
    }

    public static function getAll()
    {
      return $_COOKIE;
    }
  }
?>
